package training.bms.business;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import training.framework.persistence.AbstractEntity;

@Entity
@Table(name="POS_POST")
public class Post extends AbstractEntity<Integer>{
	private Integer identifier;
	private String title;
	private String content;
	private Date creationDate;
	private Blog blog;

	public void setIdentifier(Integer identifier) {
		this.identifier = identifier;
	}

	@Id
	@Column(name="POS_IDENTIFIER")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public Integer getIdentifier() {
		return identifier;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	@Column(name="POS_TITLE")
	@NotNull
	@Size(min=1, max=100, message="Please specify the title of this post (100 characters maximum)")
	public String getTitle() {
		return title;
	}

	public void setContent(String content) {
		this.content = content;
	}	

	@Column(name="POS_CONTENT")
	@NotNull
	@Size(min=1, max=10000, message="Please specify the content of this post (10000 characters maximum)")		
	public String getContent() {
		return content;
	}
	
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}
	
	@NotNull
	@Column(name="POST_CREATION_DATE")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreationDate() {
		return creationDate;
	}

	public void setBlog(Blog blog) {
		this.blog = blog;
	}
	
	@NotNull
	@ManyToOne
	@JoinColumn(name="BLO_IDENTIFIER")
	public Blog getBlog() {
		return blog;
	}
}
